package com.example.service.impl;

import com.example.entity.po.Primary;
import com.example.mapper.PrimaryMapper;
import com.example.service.PrimaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PrimaryServiceImpl implements PrimaryService {

    @Autowired
    private PrimaryMapper primaryMapper;

    //查找合作学校
    @Override
    public List<Primary> queryPrimary() {
        return primaryMapper.queryPrimaryOrPlace(0);
    }

    //添加合作学校
    @Override
    public int addPrimarySchool(Primary primary) {
        primary.setPlaceType(0);
        return primaryMapper.addSchoolOrPlace(primary);
    }

    //添加教学点
    @Override
    public int addPlace(Primary primary) {
        primary.setPlaceType(1);
        return primaryMapper.addSchoolOrPlace(primary);
    }

    //删除教学点
    @Override
    public int deletePlace(int id) {
        return primaryMapper.deletePrimaryOrPlace(id);
    }

    //修改教学点
    @Override
    public int updatePlace(Primary primary) {
        return primaryMapper.updatePrimaryOrPlace(primary);
    }

    //模糊查询教学点
    @Override
    public List<Primary> fuzzyPlace(String schoolName) {
        return primaryMapper.fuzzyPrimaryOrPlace(schoolName,1);
    }

    //删除合作学校
    @Override
    public int deletePrimary(int id) {
        return primaryMapper.deletePrimaryOrPlace(id);
    }

    //修改合作学校
    @Override
    public int updatePrimary(Primary primary) {
        return primaryMapper.updatePrimaryOrPlace(primary);
    }

    //模糊查询合作小学
    @Override
    public List<Primary> fuzzyPrimary(String schoolName) {
        return primaryMapper.fuzzyPrimaryOrPlace(schoolName,0);
    }

    //查找教学点
    @Override
    public List<Primary> queryPlace() {
        return primaryMapper.queryPrimaryOrPlace(1);
    }
}
